<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="years">年
    <input type="text" name="" id="month">月
    <button id="btn">是本月1号的</button>
    <input type="text" name="" id="days">天 距离1900-1-1有
    <input type="text" name="" id="days2">天 星期
    <input type="text" name="" id="weekdays">
    <input style="width: 200px;height: 200px;border: 1px solid black;margin:100px auto;display: inline;" id="div"></input>
    <script>
        document.getElementById("btn").onclick = function() {
            var _years = Number(document.getElementById("years").value),
                _month = Number(document.getElementById("month").value),
                _days = Number(document.getElementById("days").value);
            var tabledays = 1;

            function doc() {
                document.getElementById("days2").value = tabledays;
            }

            function doc1() {
                document.getElementById("days").value = tabledays;
            }

            function doc2() {
                document.getElementById("weekdays").value = tabledays;
            }


            function newday() {
                switch (i) {
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                        _days = 30;
                        break;
                    case 2:
                        _days = _years % 4 === 0 && _years % 100 !== 0 || _years % 400 === 0 ? 29 : 28;
                        break;
                    default:
                        _days = 31;
                }
            }
            for (var i = 1; i < _month; i++) {
                newday();
                tabledays += _days;
            }
            doc1();
            for (var o = 1900; o < _years; o++) {
                tabledays += o % 4 === 0 && o % 100 !== 0 || o % 400 === 0 ? 366 : 365;
            }
            doc();
            tabledays = tabledays % 7;
            switch (tabledays) {
                case 0:
                    document.getElementById("weekdays").value = "星期天";
                    break;
                case 1:
                    document.getElementById("weekdays").value = "星期一";
                    break;
                case 2:
                    document.getElementById("weekdays").value = "星期二";
                    break;
                case 3:
                    document.getElementById("weekdays").value = "星期三";
                    break;
                case 4:
                    document.getElementById("weekdays").value = "星期四";
                    break;
                case 5:
                    document.getElementById("weekdays").value = "星期五";
                    break;
                case 6:
                    document.getElementById("weekdays").value = "星期六";
                    break;
                default:
                    break;
            }
            // doc2();

            i = _month;
            switch (i) {
                case 4:
                case 6:
                case 9:
                case 11:
                    _days = 30;
                    break;
                case 2:
                    _days = _years % 4 === 0 && _years % 100 !== 0 || _years % 400 === 0 ? 29 : 28;
                    break;
                default:
                    _days = 31;
            }
            var sum = 0;
            for (var p = 1; p <= _days; p++) {
                console.log(p + "\n");
                document.getElementById("div").value = p;
                sum += 1;
                if (sum % 7 === 0) {
                    console.log("<br>");
                    document.getElementById("div").value = p;
                }
            }
        }
    </script>
</body>

</html>